package com.sairobo.base.common.support;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.sairobo.base.common.utils.ThumbnailUtil;

import java.io.IOException;

/**
 * 更新保存时候-加上缩略图后缀
 * 参考：https://developer.qiniu.com/dora/manual/1279/basic-processing-images-imageview2
 */
public class ThumbnailDeSerializer extends JsonDeserializer<String> {

    @Override
    public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        String str = jp.getText();
        return ThumbnailUtil.getThumbUrl(str);
    }

}
